package com.jolink.omiis.wechat.redis;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.jolink.omiis.wechat.api.WeChatServiceApiUtil;
import com.jolink.omiis.wechat.keys.IPreferences;

public class JedisMQMessageWorker implements Runnable {

	private static final Logger logger = LoggerFactory.getLogger(JedisMQMessageWorker.class);

	@Autowired
	private WeChatServiceApiUtil serviceUtil;

	@Autowired
	private JedisMessageListener jedisMessageListener;

	@Override
	public void run() {
		logger.info("开始监听管理台配置变更.....");
		IRedisProcessor redis = serviceUtil.getRedisProcessor();
		try {
			redis.subscribe(jedisMessageListener, IPreferences.REFRESH_MODEL_SUBJECT);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
		}
	}
}
